#include <vector>
using namespace std;
class Solution {
public:
    vector<int> countBits(int n) {
        vector<int> ret;
        for(int i = 0 ; i <= n ; i++){
            int number = 0;
            int tmp = i;
            while(tmp){
                tmp &= (tmp-1);
                number++;
            }
            ret.push_back(number);
        }
        return ret;
    }
};